package com.crm.service.impl;

import com.crm.entity.User;
import com.crm.mapper.UserMapper;
import com.crm.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author crm
 * @since 2020-06-05
 */
@Service//表示当前类是service层，也表示把当前类交给spring管理，ioc控制反转，需要时由spring创建对象
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
                             //继承了mybatis plus的接口实现，基本的增删改查方法都已经帮我们实现了
    @Resource
    private UserMapper userMapper;//注入mapper，因为service要调用mapper
    @Override
    public User findByName(String userName) {
        return userMapper.findByName(userName);
    }

    @Override
    public Integer updatePassWord(String userName) {
        return userMapper.updatePassWord(userName);
    }

    @Override
    public List<User> getAllUser(User user) {
        return userMapper.getAllUser(user);
    }

    @Override
    public Integer lockUser(Integer uid, Integer isLockout) {
        return userMapper.lockUser(uid,isLockout);
    }

    @Override
    public List<Integer> getRidByUid(User user) {
        return userMapper.getRidByUid(user);
    }

    @Override
    public List<User> getRname(Integer rid) {
        return userMapper.getRname(rid);
    }

    @Override
    public List<User> selectUserByRid(Integer rid) {
        return userMapper.selectUserByRid(rid);
    }

    @Override
    public Integer setPwd(Integer uid, String newPassword) {
        return userMapper.setPwd(uid,newPassword);
    }

}
